package com.andreiamariei.tema6.services;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.andreiamariei.tema6.entities.Category;

@SuppressWarnings("unchecked")
@Stateless
public class CategoryService {

	
	@PersistenceContext
	private EntityManager em;
	
	public List<Category> findAll() {
		
		List<Category> entities = em.createQuery(
				"select category from Category as category").getResultList();
		
		return entities;
	}

	public Category find(Long id) {
		Category category = em.find(Category.class, id);
		return category;
	}
	
}
